package com.diy.yuhaofilm.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.diy.yuhaofilm.R
import com.itheima.player.model.bean.HomeItemBean
import com.squareup.picasso.Picasso

/**
 *@Class: HomeItemView
 *@Description:()
 *@Date: 2021/4/8  13:53
 *@Company:
 *@author: yuhao
 *@Version: v1.0
 */
class HomeItemView : RelativeLayout{

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )
    /**
     * 初始化方法
     */
    init {
        View.inflate(context, R.layout.item_home,this)
    }

    /**
     * 刷新条目view数据
     */
    public fun setData(data: HomeItemBean,title:TextView,desc:TextView,bg:ImageView) {
        //歌曲名称
        title.setText(data.title)
        //简介
        desc.setText(data.description)
        //背景图片
        Picasso.with(context).load(data.posterPic).into(bg)
    }


}